/*
 * Ellipse.cpp
 *
 *  Created on: 2010-9-4
 *      Author: try
 */

#include "Ellipse.h"
#include "ControlPoint.h"
#include "../WorkLayer.h"

namespace S {
  Ellipse::Ellipse(real x, real y, real w, real h)
    :Shape(x, y, w, h) {

  }

  Ellipse::~Ellipse() {
    if (path)
      delete path;
  }

  void Ellipse::createPath() {
    if (path) delete path;
    path = new Gdiplus::GraphicsPath();
    createBoundRect();

    getBoundRect(&shapeRect, -1.0f);
    if(!(shapeRect.Width < 0 || shapeRect.Height < 0)){
      path->AddEllipse(shapeRect);
    }

    //构建控制点数据
    if(isSelected()){
      buildControlPoint();
    }

    setModified(true);
  }

  void Ellipse::draw(Gdiplus::Graphics* g) {
    //绘制椭圆
    g->FillPath(brush, path);
    g->DrawPath(pen, path);

//    setModified(false);
//    setRedraw(false);
  }

}

